// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Windows.ApplicationModel.DataTransfer;
using WinUIGallery.Helpers;

namespace WinUIGallery.Controls;

public sealed partial class ColorTile : UserControl
{
    public string ColorName
    {
        get { return (string)GetValue(ColorNameProperty); }
        set { SetValue(ColorNameProperty, value); }
    }
    public static readonly DependencyProperty ColorNameProperty =
        DependencyProperty.Register("ColorName", typeof(string), typeof(ColorTile), new PropertyMetadata(""));

    public string ColorExplanation
    {
        get { return (string)GetValue(ColorExplanationProperty); }
        set { SetValue(ColorExplanationProperty, value); }
    }
    public static readonly DependencyProperty ColorExplanationProperty =
        DependencyProperty.Register("ColorExplanation", typeof(string), typeof(ColorTile), new PropertyMetadata(""));

    public string ColorBrushName
    {
        get { return (string)GetValue(ColorBrushNameProperty); }
        set { SetValue(ColorBrushNameProperty, value); }
    }
    public static readonly DependencyProperty ColorBrushNameProperty =
        DependencyProperty.Register("ColorBrushName", typeof(string), typeof(ColorTile), new PropertyMetadata(""));

    public string ColorValue
    {
        get { return (string)GetValue(ColorValueProperty); }
        set { SetValue(ColorValueProperty, value); }
    }
    public static readonly DependencyProperty ColorValueProperty =
        DependencyProperty.Register("ColorValue", typeof(string), typeof(ColorTile), new PropertyMetadata(""));

    public bool ShowSeparator
    {
        get { return (bool)GetValue(ShowSeparatorProperty); }
        set { SetValue(ShowSeparatorProperty, value); }
    }

    // Using a DependencyProperty as the backing store for ShowSeparator.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty ShowSeparatorProperty =
        DependencyProperty.Register("ShowSeparator", typeof(bool), typeof(ColorTile), new PropertyMetadata(true));


    public bool ShowWarning
    {
        get { return (bool)GetValue(ShowWarningProperty); }
        set { SetValue(ShowWarningProperty, value); }
    }

    // Using a DependencyProperty as the backing store for ShowSeparator.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty ShowWarningProperty =
        DependencyProperty.Register("ShowWarning", typeof(bool), typeof(ColorTile), new PropertyMetadata(false));


    public ColorTile()
    {
        this.InitializeComponent();
    }

    private void CopyBrushNameButton_Click(object sender, RoutedEventArgs e)
    {
        DataPackage package = new DataPackage();
        package.SetText(ColorBrushName);
        Clipboard.SetContent(package);

        UIHelper.AnnounceActionForAccessibility(sender as Button, "Brush name copied to clipboard", "BrushNameCopiedSuccessNotificationId");
    }
}
